<%--
  Created by IntelliJ IDEA.
  User: qpx
  Date: 2018/4/19
  Time: 22:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<%--<script src="https://cdn.bootcss.com/jquery.form/4.2.2/jquery.form.js"></script>--%>
<script src="https://cdn.bootcss.com/jquery.form/4.2.2/jquery.form.min.js"></script>
<body>

<form id="uploadForm" enctype="multipart/form-data" method="post">
    <input id="upfile" type="file" name="upfile">
    <input type="button" value="导入" id="upLoadPayerCreditInfoExcel" name="btn">
</form>
<a href="/creditInfo/downLoadPayerCreditInfoExcel">导出</a>
<%--<input type="button" name="daoru" id="daoru" value="导入">--%>
<%--<input type="button" name="daochu" id="daochu" value="导出" >--%>
<script>
$('#upLoadPayerCreditInfoExcel').click(function(){
    var cacheVersion=$("#cacheVersion").val();
    if(checkData()){
        $('#uploadForm').ajaxSubmit({
        url:$("#root").val()+'/creditInfo/uploadReceiverCreditInfoExcel',
        data:{'cacheVersion':cacheVersion},
        dataType: 'text'
    });
}
});

//JS校验form表单信息
function checkData(){
    var fileDir = $("#upfile").val();
    var suffix = fileDir.substr(fileDir.lastIndexOf("."));
    if("" == fileDir){
        alert("选择需要导入的Excel文件！");
        return false;
    }
    if(".xls" != suffix && ".xlsx" != suffix ){
        alert("选择Excel格式的文件导入！");
        return false;
    }
    return true;
}
</script>
</body>
</html>
